package service;

import dao.DepartmentDao;
import dao.DepartmentDaoImpl;
import pojo.Department;

import java.util.List;

/**
 * @author 陈金平
 * @Description
 * @create 2020/11/19 12:02
 */
public class DepartmentServiceImpl implements DepartmentService{
    private DepartmentDao departmentDao = new DepartmentDaoImpl();
    @Override
    public List<Department> getAllDepartments() {
        return departmentDao.selectAllDepartments();
    }

    @Override
    public Integer addOneDepartment(Department department) {
        Integer departmentId = departmentDao.insertOneDepartment(department);
        if (departmentId==null){
            return 0;
        }
        return departmentId;
    }

    @Override
    public Integer setOneDepartment(Department department) {
        return departmentDao.updateOneDepartment(department);
    }

    @Override
    public Department getSetDepartmentById(Integer did) {
        return departmentDao.selectDepartmentById(did);
    }

    @Override
    public Integer delAllDepartments(List<Integer> dIds) {
        return departmentDao.deleteAllDepartments(dIds);
    }
    @Override
    public Integer delAllDepartment(Integer did) {
        return departmentDao.deleteAllDepartment(did);
    }
}
